package com.cx.common.core.dto.request;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;

import javax.validation.Valid;

@ApiModel(description = "请求对象")
@SuperBuilder
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Req<T> extends BaseReq {

    private static final long serialVersionUID = 1L;

    @Valid
    @ApiModelProperty(value = "请求参数，可为基本类型（包装类），可以为其它可序列化对象", required = true)
    private T data;

    public static <T> Req<T> create(long time, String ip, String id, Integer role, Byte system) {
        return Req.<T>builder()
                .time(time).ip(ip).id(id).role(role).system(system)
                .build();
    }

    public static <T> Req<T> create() {
        return Req.<T>builder().build();
    }
}
